function websocketonopen() {
    console.log("WebSocket连接成功");
}
function websocketonerror(e) {
    console.log("WebSocket连接发生错误");
}
function websocketonmessage(e) {
    // console.log(e.data); // console.log(e);              
}
function websocketclose(e) {
    // console.log("connection closed (" + e.code + ")");
}
function initWebSocket(params) {
    // WebSocket与普通的请求所用协议有所不同，ws等同于http，wss等同于https
    var webSocketUrl = 'ws://192.168.0.125:8089/api/websocket/' + params
    this.websock = new WebSocket(webSocketUrl);
    this.websock.onopen = this.websocketonopen;
    this.websock.onerror = this.websocketonerror;
    this.websock.onmessage = this.websocketonmessage;
    this.websock.onclose = this.websocketclose;
}

export { initWebSocket, 
    websocketonopen,
    websocketonerror,
    websocketonmessage,
    websocketclose
 }